Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Runtime.Serialization
Imports System.Net
Imports System.IO
Imports System.Linq
Imports System.Collections.Generic
Imports System.Xml


Public Class Pago
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnbuscar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnbuscar.Click
        Dim objCliente As New ClienteBL

        If txtdni.Text = "" Then
            MsgBox("Debe Ingresar el DNI")
            Exit Sub
        Else
            Dim dt As DataTable = objCliente.ClientexDni(txtdni.Text).Tables(0)
            If dt.Rows.Count = 0 Then
                ScriptManager.RegisterClientScriptBlock(Me, GetType(Button), "mensaje", "alert('No existe el cliente')", True)
            End If
            lblNombre.Text = IIf(dt.Rows(0).Item(0).ToString = "", "", dt.Rows(0).Item(0).ToString())
            lblApellido.Text = IIf(dt.Rows(0).Item(1).ToString = "", "", dt.Rows(0).Item(1).ToString())

            Dim objProducto As New ProductoBL
            chkProducto.DataSource = objProducto.ListaProducto(txtdni.Text)
            chkProducto.DataTextField = "NomProd"
            chkProducto.DataValueField = "CodigoProducto"
            chkProducto.DataBind()
        End If

        Dim proxy As New WebClient()
        Dim abc As Byte() = proxy.DownloadData(New Uri("http://localhost:1805/Productos/25854703"))
        Dim strm = New MemoryStream(abc)
        Dim obj As New DataContractSerializer(GetType(String))
        Dim result As String = obj.ReadObject(strm).ToString()


        'Dim objProducto As New ProductoBL
        'chkProducto.DataSource = objProducto.ListaProducto(txtdni.Text)
        'chkProducto.DataTextField = "NomProd"
        'chkProducto.DataValueField = "CodigoProducto"
        'chkProducto.DataBind()


        'Dim proxy As New WebClient()
        'Dim abc As Byte() = proxy.DownloadData(New Uri("http://localhost:1805/Productos/" + txtdni.Text))
        'Dim strm = New MemoryStream(abc)

        'Dim ds As New DataSet
        'ds.ReadXml(strm)
        ''Dim strm = New MemoryStream(abc)
        ''Dim obj As New DataContractSerializer(GetType(String))
        ''Dim result As String = obj.ReadObject(strm).ToString()

        'chkProducto.DataSource = ds
        'chkProducto.DataTextField = "NomProd"
        'chkProducto.DataValueField = "CodigoProducto"
        'chkProducto.DataBind()

    End Sub
End Class